package org.example.service.impl;

import org.example.dao.BookDao;
import org.example.service.BookService;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class BookServiceImpl implements BookService, InitializingBean, DisposableBean {

    // 删除new创建的Dao对象
    // private BookDao bookDao = new BookDaoImpl();
    private BookDao bookDao;

    @Override
    public void save() {
        System.out.println("BookServiceImpl-save..");
        bookDao.save();
    }

    //提供set方法
    public void setBookDao(BookDao bookDao) {
        System.out.println("BookServiceImpl-setBookDao..");
        this.bookDao = bookDao;
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("BookServiceImpl-destroy..");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("BookServiceImpl-afterPropertiesSet..");
    }
}
